package org.lanqiao.tjut.db;

import java.io.IOException;
import java.util.Properties;

import javax.sql.DataSource;

import org.apache.commons.dbcp2.BasicDataSourceFactory;

public class DBDataSource {
	private static DataSource dataSource;
	private DBDataSource(){
		
	}
public  static DataSource getDataSource(){
	if(dataSource == null){
		try {
			Properties prop = new Properties();
			prop.load(DBDataSource.class.getClassLoader().getResourceAsStream("db.properties"));
			dataSource = BasicDataSourceFactory.createDataSource(prop);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println("生成数据库连接池错误："+e.getMessage());
		}
	}
	return dataSource;
}
}
